package com.cykj.admin.controller;

import com.cykj.admin.annotation.MyLog;
import com.cykj.admin.service.IAdminService;
import com.cykj.admin.vo.AdminVO;
import com.cykj.common.dto.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject:@BelonqsPackage:com.cykj.admin.controller
 * @Author:jiangna
 * @CreateTime:2025-08-15 10:50
 */
@Tag(name = "AdminController", description = "平台端管理员的接口")
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private IAdminService adminService;

    /**
     * @Description: 管理员登录
     * @Param: [adminVO]
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @Operation(summary = "平台端管理员登录接口")
    @GetMapping("/login")
    public ResponseDTO login(AdminVO adminVO) {
        return adminService.login(adminVO);
    }

    /**
     * @Description: 查询所有管理员数据 / 根据查询条件查询管理员
     * @Param: 账号、开始时间、结束时间、状态
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @Operation(summary = "平台端查询所有管理员数据信息接口")
    @GetMapping("/selectAdminsByCondition")
    public ResponseDTO selectAdminsByCondition(AdminVO adminVO) {
        return adminService.selectAdminsByCondition(adminVO);
    }

    /**
     * @Description: 重置管理员密码
     * @Param: 管理员ID
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @MyLog("重置密码")
    @Operation(summary = "平台端重置管理员密码接口")
    @PutMapping("/resetPassword/{adminId}")
    public ResponseDTO resetPassword(@PathVariable("adminId") Integer adminId) {
        return adminService.resetPassword(adminId);
    }


    /**
     * @Description: 拉黑管理员
     * @Param: [adminVO]
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @MyLog("拉黑管理员")
    @Operation(summary = "平台端禁用管理员接口")
    @DeleteMapping("/deleteAdmin")
    public ResponseDTO deleteAdmin(AdminVO adminVO) {
        return adminService.deleteAdmin(adminVO);
    }

    /**
     * @Description: 获取管理员信息
     * @Param: []
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @Operation(summary = "平台端获取管理员信息接口")
    @GetMapping("getAdminInfo")
    public ResponseDTO getAdminInfo() {
        return adminService.getAdminInfo();
    }


    /**
     * @Description: 退出登录
     * @Param: []
     * @return: com.cykj.common.dto.ResponseDTO
     */
    @Operation(summary = "平台端管理员退出登录接口")
    @GetMapping("logout")
    public ResponseDTO logout() {
        return adminService.logout();
    }
}
